<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <!-- id形式 -->
    <button id="butt">唐伯虎</button>
    <script>
        var but = document.getElementById('butt');
        // 事件源.事件类型 = 事件处理程序
        but.onclick = function() {
            alert('点秋香');
        }
    </script>

    //
    <!-- 标签名形式 -->
    <!-- <button>唐伯虎</button>

    <script>
        var but = document.getElementsByTagName('button');
        but[0].onclick = function() {
            alert('点秋香');
        }
    </script> -->
</body>

</html>